const acl = require("express-acl");
const { BASE_PATH } = process.env;
const unlessPath = ["/login", "/init"].map((el) => `${BASE_PATH}${el}`);
module.exports = (db) => {
  const rules = db.get("rules").value();
  acl.config({
    rules,
    decodedObjectName: "auth",
  });
  return acl.authorize.unless({ path: unlessPath });
};
